package com.hao.wms.util;

import com.hao.wms.domain.Employee;
import com.opensymphony.xwork2.ActionContext;

import java.util.Set;

public class UserContext {
    private static final String USERINSESSION = "USERINSESSION";
    private static final String PERMISSIONS = "PERMISSIONS";
    public static void setUser( Employee emp) {
        if(emp!=null){
            ActionContext.getContext().getSession().put(USERINSESSION,emp);
        }else{
            ActionContext.getContext().getSession().clear();
        }
    }

    public static void setPermission(Set<String> permissions) {
        ActionContext.getContext().getSession().put(PERMISSIONS,permissions);

    }
    public static Set<String> getPermission(){
        return (Set<String>) ActionContext.getContext().getSession().get(PERMISSIONS);
    }

    public static Employee getUser() {
        return (Employee) ActionContext.getContext().getSession().get(USERINSESSION);
    }
}
